package com.yanqu.road.dataHelper.action.excel;

import com.yanqu.road.dao.db.DbNameStrategy;
import com.yanqu.road.dataHelper.manager.BaseMgr;

import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class ActivityBestRankLogic extends BaseMgr {

    public ActivityBestRankLogic(){

    }

    public List<Integer> getActivityIdsByType(int type) {
        List<Integer> list = new ArrayList<>();
        ResultSet rs = null;
        CallableStatement call = null;
        String sql = "select * from t_s_activity_main WHERE type = ? ";
        //
        try {
            getDb().setConnName(DbNameStrategy.getServerDb());
            call = getDb().getConnection().prepareCall(sql);
            call.setInt(1, type);
            rs = call.executeQuery();
            while (rs.next()) {
                int activityId = rs.getInt("activityId");
                list.add(activityId);
            }
        } catch (SQLException ex) {
            logger.error("getActivityIdsByType error", ex);
        } finally {
            getDb().closeConnection(call, null);
        }
        return list;
    }

}
